# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module(
    name = "ink",
    version = "0.0.1",
)

git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

#################################################################################
## Toolchain setup
#################################################################################

bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.2.2")
bazel_dep(name = "toolchains_llvm", version = "1.5.0")

# Configure and register the LLVM toolchain for host builds.

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
llvm.toolchain(llvm_version = "19.1.0")
use_repo(llvm, "llvm_toolchain")

register_toolchains("@llvm_toolchain//:all")

# Configure the Android NDK toolchain for NDK builds. Don't register that here so it's not required
# for builds that don't need it. Those configs can register those in --extra_toolchains.
bazel_dep(name = "rules_android_ndk", version = "0.1.3")

android_ndk_repository_extension = use_extension(
    "@rules_android_ndk//:extension.bzl",
    "android_ndk_repository_extension",
)
use_repo(android_ndk_repository_extension, "androidndk")

#################################################################################
## Direct dependencies
#################################################################################

bazel_dep(
    name = "abseil-cpp",
    version = "20250512.0",
    repo_name = "com_google_absl",
)

git_repository(
    name = "ink_stroke_modeler",
    commit = "748f84a30335b773e073fd1cf31c591be0a6b77e",  # Head as of 2025-06-17
    remote = "https://github.com/google/ink-stroke-modeler.git",
)

git_repository(
    name = "libtess2",
    commit = "446bae6dfb4c3efb43cb2764379574dcb4f0ee6c",  # Head as of 2025-04-25
    remote = "https://github.com/memononen/libtess2.git",
)

bazel_dep(name = "protobuf", version = "31.1")
bazel_dep(name = "rules_android", version = "0.6.0")
bazel_dep(name = "rules_jni", version = "0.11.1")

git_repository(
    name = "skia",
    commit = "fb92a016ef1dd54b027d022e72689497eb5b6c0e",  # Head as of 2025-09-08
    remote = "https://github.com/google/skia.git",
)

# Skia configuration
local_repository = use_repo_rule(
    "@bazel_tools//tools/build_defs/repo:local.bzl",
    "local_repository",
)

local_repository(
    name = "skia_user_config",
    path = "skia_user_config",
)

#################################################################################
## Development dependencies
#################################################################################
bazel_dep(
    name = "googletest",
    version = "1.17.0",
    dev_dependency = True,
    repo_name = "com_google_googletest",
)
bazel_dep(
    name = "google_benchmark",
    version = "1.8.3",
    dev_dependency = True,
    repo_name = "com_google_benchmark",
)
bazel_dep(
    name = "fuzztest",
    version = "20250214.0",
    dev_dependency = True,
    repo_name = "com_google_fuzztest",
)

# Depend on a later version of Riegeli than the one in Fuzztest to avoid an
# incompatibility with the version of Abseil that we use. We don't use this
# directly, so it can be removed when we upgrade to a version of Fuzztest
# that depends on a later version (pending upgrade in
# https://github.com/google/fuzztest/pull/1742).
bazel_dep(
    name = "riegeli",
    version = "0.0.0-20250706-c4d1f27",
    dev_dependency = True,
)

#################################################################################
## Transitive dependencies
#################################################################################

# We can remove these when Skia has a MODULE.bazel file.
# See: https://g-issues.skia.org/issues/367315534
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "libpng", version = "1.6.47")
